]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensionUtils: Support subdirectories in getCurrentExtension
authorJasper St. Pierre <jstpierre@mecheye.net>
Mon, 28 May 2012 21:21:02 +0000 (17:21 -0400)
committerJasper St. Pierre <jstpierre@mecheye.net>
Tue, 29 May 2012 18:36:16 +0000 (14:36 -0400)
Some extensions may have complex layouts with multiple subdirectories.
Currently, getCurrentExtension doesn't support this, as it uses a regex
and assume's that the last path's component's parent is all that's needed.
Fix this.

https://bugzilla.gnome.org/show_bug.cgi?id=677001

js/misc/extensionUtils.js

index 82ded012528868252f8e3549616897d2c0011d1a..77a49d5b535a0b02bc5c6f06e50b29f23b827ed5 100644 (file)
@@ -40,13 +40,18 @@ function getCurrentExtension() {
         throw new Error('Could not find current extension');
 
     let path = match[1];
-    let uuid = GLib.path_get_basename(GLib.path_get_dirname(path));
-
-    let extension = extensions[uuid];
-    if (extension === undefined)
-        throw new Error('Could not find current extension');
+    let file = Gio.File.new_for_path(path);
+
+    // Walk up the directory tree, looking for an extesion with
+    // the same UUID as a directory name.
+    while (file != null) {
+        let extension = extensions[file.get_basename()];
+        if (extension !== undefined)
+            return extension;
+        file = file.get_parent();
+    }
 
-    return extension;
+    throw new Error('Could not find current extension');
 }
 
 /**